<template>
	<ScorllRefresher @refresh="loadData">
		<view v-for="item of list" :key="item.spuId" class="inline-flex fill aic legal-counsel"
			@click.stop="tapToServiceDetail(item.spuId)">
			<image :src="item.mainImgUrl"></image>
			<view class="ellipsis">{{item.spuName}}</view>
		</view>
	</ScorllRefresher>
</template>
<script lang="ts">
	import { defineComponent } from "vue";
	export default defineComponent({
		// #ifdef MP-WEIXIN
		options: {
			virtualHost: true,
			// styleIsolation: 'shared'
		},
		// #endif
	})
</script>
<script setup lang="ts">
	import ScorllRefresher from '@/components/scroll-refresher/scroll-refresher.vue';
	import { ServiceType } from '@/utils/constant';
	import { getServiceList } from '@/apis/service';
	import { ref, watchEffect } from 'vue';
	const props = withDefaults(defineProps<{
		parentId : number;
	}>(), {
		parentId: 4
	});

	const list = ref<AnyObj[]>([]);


	function tapToServiceDetail(spuId : string) {
		uni.navigateTo({
			url: `/pages-service/service-detail/service-detail?spuId=${spuId}`
		})
	}

	function loadData() {
		getServiceList(props.parentId).then((res) => {
			list.value = res.rows;
		});
	}

	watchEffect(() => {
		loadData();
	})
</script>

<style lang="scss">
	.legal-counsel {
		height: 160rpx;
		padding: 32rpx;

		image {
			display: inline-flex;
			width: 128rpx;
			height: 128rpx;
			flex-shrink: 0;
			margin-right: 20rpx;
			border-radius: 10rpx;
			background: #843B3B;
		}

		text {
			padding-left: 40rpx;
			color: #101010;
			font-size: 30rpx;
			font-weight: 400;
		}
	}
</style>